﻿
#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
#define DISABLESTEAMWORKS
#endif
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LicenseBook : MonoBehaviour
{
    public Text m_Pass1L;
    public Text m_Pass2L;
    public Text m_LevelL;
    public Text m_DateL;
    bool isNiuBi = false;
    public Driver.DriveLevel Level {
        get { return m_Level; }
        set {

            m_Level = value;
            int weight = Player.Instance.DriveLicenseState[(int)m_Level, 0] + Player.Instance.DriveLicenseState[(int)m_Level, 1] + Player.Instance.DriveLicenseState[(int)m_Level, 2];
            
            if(weight>=3)
            {
                if (Commander.Instance.m_Characters[(int)m_Level] == null)
                {
                    Commander.Instance.m_Characters[(int)m_Level] = CharacterFactory.Instance.RandomCreateOne();
                    Commander.Instance.save();
                }
                var character = Commander.Instance.m_Characters[(int)m_Level];
                if (weight == 3)
                {
                    m_Pass1L.text = character.m_Name;
                    m_Pass2L.text = "随便";
                }
                else if (weight > 3 && weight < 6)
                {
                    m_Pass1L.text = character.m_Name;
                    m_Pass2L.text = "还行";
                }
                else if (weight == 6)
                {
                    m_Pass1L.text = character.m_Name;
                    m_Pass2L.text = "牛逼";
                    isNiuBi = true;
                }
            }

            switch(m_Level)
            {
                case Driver.DriveLevel.LEVEL_D:
                    m_LevelL.text = "D";
                    break;
                case Driver.DriveLevel.LEVEL_C:
                    m_LevelL.text = "C";
                    break;
                case Driver.DriveLevel.LEVEL_B:
                    m_LevelL.text = "B";
                    break;
                case Driver.DriveLevel.LEVEL_A:
                    m_LevelL.text = "A";
                    break;
                case Driver.DriveLevel.LEVEL_AP:
                    m_LevelL.text = "AP";
                    break;
            }
        }
    }
    public Driver.DriveLevel m_Level;

    void Start()
    {
#if !DISABLESTEAMWORKS
        if (isNiuBi && UtilsGame.IsSteamMG())
        {
            Steamworks.SteamUserStats.SetAchievement("NIU_BI");
            Steamworks.SteamUserStats.StoreStats();
        }
#endif
    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetMouseButtonDown(0))
        {
            gameObject.SetActive(false);
        }
    }
}
